<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>物品归还系统</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="css/bootstrap.min.css-v=3.3.5.css" rel="stylesheet">
    <link href="css/font-awesome.min.css-v=4.4.0.css" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css-v=4.0.0.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
    <style>
        #zhuti1 {
            height: 100%;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" id="zhuti1">

                <div class="ibox-title">
                    <h3 style="font-weight: 600;margin-top: 0;">归还物品</h3>
                </div>

                <div class="ibox-content">
                    <form method="post" id="bigform3" autocomplete="off" class="form-horizontal layui-form">
<!--                      第一行-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">归还人</label>
                            <div class="col-sm-3">
                                <input type="text" name="returner" required placeholder="请输入归还人"
                                       class="form-control size">
                            </div>
                            <label class="col-sm-2 control-label">联系方式</label>
                            <div class="col-sm-4">
                                <input type="text" name="returner_phone" required placeholder="请输入归还人的联系方式"
                                       class="form-control size">
                            </div>
                        </div>
<!--                        第二行-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">校园卡号</label>
                            <div class="col-sm-3">
                                <input type="text" name="returner_card" required placeholder="请输入归还人的校园卡号"
                                       class="form-control size">
                            </div>
                            <label class="col-sm-2 control-label">值班人员</label>
                            <div class="col-sm-4">
                                <input type="text" name="zhibanren" required placeholder="请输入值班人员"
                                       class="form-control size">
                            </div>
                        </div>

<!--                        &lt;!&ndash;第三行&ndash;&gt;-->
<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-2 control-label">所有借出物品编号</label>-->
<!--                            <div class="col-sm-3">-->
<!--                                <input type="text" name="sign1" required placeholder="请输入所有借出物品编号"-->
<!--                                       class="form-control size">-->
<!--                            </div>-->

<!--                            <label class="col-sm-2 control-label"已归还物品编号</label>-->
<!--                            <div class="col-sm-4">-->
<!--                                <input type="text" name="sign2" required placeholder="请输入已归还物品的所有编号"-->
<!--                                       class="form-control size">-->
<!--                            </div>-->
<!--                        </div>-->

                        <div class="form-group">
                            <label class="col-sm-2 control-label">所有借出物品编号</label>
                            <div class="col-sm-3">
                                <input type="text" name="sign1" required placeholder="请输入所有借出物品编号"
                                       class="form-control size">
                            </div>
                            <label class="col-sm-2 control-label">已归还物品编号</label>
                            <div class="col-sm-4">
                                <input type="text" name="sign2" required placeholder="请输入已归还物品的所有编号"
                                       class="form-control size">
                            </div>
                        </div>

                        <!--第四行-->
                        <div class="form-group layui-form">
                            <label class="col-sm-2 control-label">未归还物品编号</label>
                            <div class="col-sm-3">
                                <input type="text" name="sign3" required placeholder="请输入未归还物品的所有编号"
                                       class="form-control size">
                            </div>


                            <label class="col-sm-2 control-label">归还物品是否有损坏</label>
                            <!--                            <input name="shi" type="button" style="margin-right: 1%;margin-left: 18px;" id="shi"-->
                            <!--                                   class="btn btn-primary" value="是">-->
                            <!--                            <input class="btn btn-white" id="fou" type="button" value="否">-->
                            <input type="checkbox" name="gongan1" lay-skin="switch" lay-filter="switchTest1"
                                   lay-text="是|否" class="form-control">

                        </div>
                        <!--弹出的损坏情况-->
                        <div class="form-group" style="display:none" zone="100" id="sunhuai">
                            <label class="col-sm-2 control-label">损坏情况</label>
                            <div class="col-sm-3">
                                <input type="text" name="after_damage_details"  placeholder="请输入损坏情况"
                                       class="form-control size">
                            </div>
                        </div>
<!--                        第五行-->
                        <div class="form-group">
                            <div class="form-group">
                                <div class="col-sm-3 col-sm-offset-4">

                                    <input name="tijiao" type="button" style="margin-right: 20%;" id="tijiao"
                                           class="btn btn-primary" value="归还">

                                    <input class="btn btn-white" id="reset" type="reset" value="重新填写">
                                </div>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.min.js-v=2.1.4"></script>
<script src="layui/layer/layer.js" type="text/javascript" charset="utf-8"></script>

<script src="js/bootstrap.min.js-v=3.3.5"></script>
<script src="js/content.min.js-v=1.0.0"></script>
<script src="js/plugins/iCheck/icheck.min.js"></script>


<script>
    // 监听是否
    layui.use('form', function () {
        var form = layui.form;
        //公安
        form.on('switch(switchTest1)', function (data) {
            // console.log(data.elem.checked);
            var ll = layui.$("input[name='gongan1']").is(':checked');
            // layui.$(test).is(':checked');
            if (data.elem.checked == false && $.trim(ll) == $.trim('true')) {
                document.getElementById('sunhuai').style.display = 'none';
            } else if (data.elem.checked == true && $.trim(ll) == $.trim('true')) {
                document.getElementById('sunhuai').style.display = 'block';
            } else if (data.elem.checked == false && $.trim(ll) == $.trim('false')) {
                document.getElementById('sunhuai').style.display = 'none';
            } else {
                document.getElementById('sunhuai').style.display = 'none';
            }
            ;
        });
        //疫情办公室
        // form.on('switch(switchTest2)', function(data){
        //     var ll= layui.$("input[name='gongan']").is(':checked');
        //
        //     if( data.elem.checked==false&&$.trim(ll)==$.trim('true')){
        //         layer.tips('温馨提示：没有备案，无法申请', data.othis);
        //         $("input[name='apply1']").prop("disabled", true);
        //     }else if( data.elem.checked==true&&$.trim(ll)==$.trim('true')){
        //         $("input[name='apply1']").prop("disabled", false);//关闭属性
        //     }else if( data.elem.checked==false&&$.trim(ll)==$.trim('false')){
        //         layer.tips('温馨提示：没有备案，无法申请', data.othis);
        //         $("input[name='apply1']").prop("disabled",true);
        //     }else{
        //         $("input[name='apply1']").prop("disabled",true);
        //     };
        // });
    });

    $(document).ready(function () {
        let id = 0;
        let state = "";

        <!--	获取url后边的参数-->
        function GetRequest() {
            const url = location.search; //获取url中"?"符后的字串
            let theRequest = new Object();
            if (url.indexOf("?") != -1)//判断不等于空
            {
                let str = url.substr(1);//抽取字符
                let strs = str.split("&");//抽取从&开始的
                for (let i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }

        // // 判断是否
        // $("#shi").on("click", function () {
        //         //得到input标签对象
        //         document.getElementById('sunhuai').style.display = 'block';
        //
        // })
        // // 判断是否
        // $("#fou").on("click", function () {
        //     //得到input标签对象
        //     document.getElementById('sunhuai').style.display = 'none';
        //
        // })


        //提交
        let x = GetRequest();
        // console.log(x);
        let idd = x.id;
        $("#tijiao").on("click", function () {

            var returner = $("input[name='returner']").val();
            var returner_phone = $("input[name='returner_phone']").val();
            var returner_card = $("input[name='returner_card']").val();
            var zhibanren = $("input[name='zhibanren']").val();
            var sign1 = $("input[name='sign1']").val();
            var sign2 = $("input[name='sign2']").val();
            var sign3 = $("input[name='sign3']").val();
            var after_damage_details = $("input[name='after_damage_details']").val();
            var is_damage;
            if(after_damage_details=="")
                is_damage="否";
            else
                is_damage="是";

            id = idd;
            // console.log(parseInt(idd))
            //传值

            $.ajax({
                type: "POST",
                url: "/returnGoods",
                data: {
                    "aid": idd,
                    "returner": returner,
                    "returner_phone": returner_phone,
                    "returner_card": returner_card,
                    "zhibanren": zhibanren,

                    //所有借出物品编号
                    "all_sign": sign1,
                    //归还物品编号
                    "return_sign":sign2,
                    //未归还物品编号
                    "notreturn_sign":sign3,

                    "after_damage_details": after_damage_details,
                    "is_damage": is_damage,


                },
                success: function (msg) {
                    if (msg == 1) {
                        layer.alert("归还成功");
                        //提交成功后清空
                        $("input[name='returner']").val("");
                        $("input[name='returner_phone']").val("");
                        $("input[name='returner_card']").val("");
                        $("input[name='zhibanren']").val("");
                        $("input[name='sign1']").val("");
                        $("input[name='sign2']").val("");
                        $("input[name='sign3']").val("");
                        $("input[name='after_damage_details']").val("");

                        document.getElementById('sunhuai').style.display = 'none';

                        window.setInterval(function () {
                            top.location.href = "/index";
                        }, 1500);
                    } else {
                        layer.alert("归还失败");
                    }

                },
                error: function (nn) {
                    layer.alert("归还失败");
                    console.log(nn);
                },
            });
            return false;
        });
        return false;
    });

</script>
</body>

</html>
